<template>
  <div>

    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>系统</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path: '/roles' }">系统角色</el-breadcrumb-item>
      <el-breadcrumb-item>新增角色</el-breadcrumb-item>
    </el-breadcrumb>

    <el-row style="margin-top: 22px;padding-top:22px;border-top: 1px solid lightgrey;">
      <el-col :span="12">
        <el-form ref="form" :model="form" label-width="6rem">
          <el-form-item label="业务系统">
            <el-select v-model="this.sysId" placeholder="请选择业务系统" disabled>
              <el-option v-for="item in [{sysId:this.sysId,sysName:this.sysName}]" :key="item.sysId" :label="item.sysName" :value="item.sysId">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="角色编码">
            <el-input v-model="form.roleCode"></el-input>
          </el-form-item>
          <el-form-item label="角色名称">
            <el-input v-model="form.roleName"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="onSubmit">保存</el-button>
            <el-button @click="onCancle">取消</el-button>
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>

  </div>
</template>

<style>
</style>

<script>
import { mapActions } from "vuex";

export default {
  name: "AddRole",
  props: ["sysId", "sysName"],
  data() {
    return {
      form: {
        roleCode: "",
        roleName: ""
      }
    };
  },
  methods: {
    ...mapActions(["reqInsertRole"]),
    onSubmit() {
      console.log("submit!");
      var payload = {
        sysId: this.sysId,
        roleCode: this.form.roleCode,
        roleName: this.form.roleName
      };
      this.reqInsertRole(payload);
    },
    onCancle() {
      this.$router.go(-1);
    }
  }
};
</script>
